﻿using UnityEngine;

public class CalculateMeshTool : MonoBehaviour
{
    // Start is called before the first frame update
    //void Start()
    //{

    //}

    // Update is called once per frame
    //void Update()
    //{

    //}

    private void OnGUI()
    {
        if (GUILayout.Button("获取mesh高度"))
        {
            var renderer = GetComponent<MeshRenderer>();
            if (renderer)
            {
                Debug.LogError("mesh大小X：" + renderer.bounds.size.x);
                Debug.LogError("mesh大小Y：" + renderer.bounds.size.y);
                Debug.LogError("mesh大小Z：" + renderer.bounds.size.z);
            }

            var spriteRender = GetComponent<SpriteRenderer>();
            if (spriteRender)
            {
                Debug.LogError("mesh大小X：" + spriteRender.bounds.size.x);
                Debug.LogError("mesh大小Y：" + spriteRender.bounds.size.y);
                Debug.LogError("mesh大小Z：" + spriteRender.bounds.size.z);
            }
        }
            

        if (GUI.Button(new Rect(100f, 50f, 100f, 50f),"切换shader"))
        {
            var objects = FindObjectsOfType<MeshRenderer>();
            foreach (var obj in objects)
            {
                if (obj.material.shader.name == "TA/GTA/RPG/CityGroundRunTime")
                {
                    obj.material.shader = Shader.Find("Mobile/Battle/Diffuse");
                }
            }
        }


        if (GUI.Button(new Rect(150f, 50f, 100f, 50f), "关闭天空和"))
        {
            RenderSettings.skybox = null;
        }
    }
}
